<?php

if (isset($_POST['poradieUp'])) {
    upravPoradie($_POST['zam'], $_POST['zamPoradie'], '-', $veduci_oddelenia);
}

if (isset($_POST['poradieDown'])) {
    upravPoradie($_POST['zam'], $_POST['zamPoradie'], '+', $veduci_oddelenia);
}

$block = false;
$dochMesiac = date("n",($bodNula + ($tyzden-1)*(7*24*60*60)));
$dochMesiac2 = date("n",($bodNula + ($tyzden-1)*(7*24*60*60) + (6*24*60*60)));

$prvyDenTyzdna = date("U",$bodNula + ($tyzden-1)*(7*24*60*60));
$poslednyDenTyzdna = date("U",$bodNula + ($tyzden-1)*(7*24*60*60) + (6*24*60*60));
$desiatyDen = date("U",mktime(0,0,0,$dochMesiac+1,10,date("Y",$bodNula + ($tyzden-1)*(7*24*60*60))));
$dnesnyDen = date("U");
$block = block($prvyDenTyzdna,$poslednyDenTyzdna,$desiatyDen,$dnesnyDen);
$upravaPoradia = false;
?>

<table style="border-collapse: collapse; font-size: 13px; text-align: center; vertical-align: middle; width: 1550px">
    <tr>
        <?php
        for ($i=0;$i<23;$i++) {
            echo '<td style="width:70px; height: 20px;"></td>';
        }
        ?>
    </tr>
    <tr>
        <td colspan="23">
            <?php
            $odd_s = "SELECT * FROM oddelenie WHERE id='".$veduci_oddelenia."' ";
            $odd_q = MySQL_Query ($odd_s);
            $odd = MySQL_Fetch_Array($odd_q);
            echo '<span style="font-size: 20px;">Oddelenie: <b>'.$odd['nazov'].'</b></span>';
            ?>
        </td>
    </tr>
    <tr>
        <td colspan="23">
            <form action="print.php?week=<?php echo $tyzden ?>" method="post" id="printForm">
                <input <?php if ($block) echo "disabled " ?> name="" value="Skopírovať plánované do reálne" type="button" onclick="copy(<?php echo ($bodNula + ($tyzden-1)*(7*24*60*60)) ?>,<?php echo $user_id; ?>,<?php echo $veduci_oddelenia; ?>)" />
                <input name="mode" type="hidden" value="week" />
                <input name="zero" type="hidden" value="<?php echo $bodNula ?>" />
                <input name="user" type="hidden" value="<?php echo $user_id ?>" />
                <input name="veduci" type="hidden" value="<?php echo $veduci_oddelenia ?>" />
                <input name="" value="Vytlačiť týždennú dochádzku" type="button" onclick="print()" /><br/><br/>
                <input <?php if ($block) echo "disabled " ?> id="nadcasButton" name="" value="Vypočítať nadčasy za tento týždeň" type="button" onclick="vypocitatNadcasy(<?php echo $veduci_oddelenia ?>,<?php echo ($bodNula + ($tyzden-1)*(7*24*60*60)) ?>,<?php echo $tyzden ?>)" />
            </form>
            <form action="tyzdenToExcel.php" method="post">
                <input name="oddelenie" value="<?php echo $veduci_oddelenia ?>" type="hidden" />
                <input name="zero" value="<?php echo $bodNula ?>" type="hidden" />
                <input name="tyzden" value="<?php echo $tyzden ?>" type="hidden" />
                <input name="" value="Exportovať týždeň do Excelu" type="submit" />
            </form>
        </td>
    </tr>
    <tr>
        <td colspan="23" style="text-align: left;">
            <br/>
            <form action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post">
                <input name="tyzden" value="<?php echo $tyzden ?>" type="hidden" />
                <?php
                if (isset($_POST['modPoradie'])&&($_POST['modPoradie']==1)) {
                    $upravaPoradia = true;
                ?>   
                <input name="modPoradie" value="0" type="hidden" />
                <input name="endPoradie" type="submit" value="Ukončiť úpravu poradia" />
                    <?php
                } else {
                    $upravaPoradia = false;
                    ?>
                <input name="modPoradie" value="1" type="hidden" />
                <input name="startPoradie" type="submit" value="Upraviť poradie" />
                    <?php   
                }     
                ?>
            </form>
        </td>
    </tr>
    <tr>
        <?php
        for ($i=0;$i<23;$i++) {
            echo '<td style="width:70px; height: 20px;"></td>';
        }
        ?>
    </tr>
    <tr style="background: #e4c9ff">
        <th style="border: 1px solid black" rowspan="2" colspan="1">Poradie</th>
        <th style="border: 1px solid black" rowspan="2" colspan="2">Meno</th>
        <th style="border: 1px solid black" rowspan="2" colspan="1">Nočných k <?php echo date("d.m. Y",($bodNula + ($tyzden-1)*(7*24*60*60) - (1*24*60*60) )); ?>*</th>
        <th style="border: 1px solid black" rowspan="2" colspan="1">Sviatkov k <?php echo date("d.m. Y",($bodNula + ($tyzden-1)*(7*24*60*60) - (1*24*60*60) )); ?>*</th>
        <th style="border: 1px solid black" rowspan="2" colspan="1">Strava k <?php echo date("d.m. Y",($bodNula + ($tyzden-1)*(7*24*60*60) - (1*24*60*60) )); ?></th>
        <th style="border: 1px solid black" rowspan="2" colspan="1">Nadčas k <?php echo date("d.m. Y",($bodNula + ($tyzden-1)*(7*24*60*60) - (1*24*60*60) )); ?>*</th>
        <th style="border: 1px solid black" rowspan="2" colspan="1">Mod k <?php echo date("d.m. Y",($bodNula + ($tyzden-1)*(7*24*60*60) - (1*24*60*60) )); ?> </th>
        <th style="border: 1px solid black" rowspan="2" colspan="1">&nbsp;</th>
        <th style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (0*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="2"><?php echo date("d-M",($bodNula + ($tyzden-1)*(7*24*60*60) + (0*24*60*60) )) ?></th>
        <th style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (1*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="2"><?php echo date("d-M",($bodNula + ($tyzden-1)*(7*24*60*60) + (1*24*60*60) )) ?></th>
        <th style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (2*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="2"><?php echo date("d-M",($bodNula + ($tyzden-1)*(7*24*60*60) + (2*24*60*60) )) ?></th>
        <th style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (3*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="2"><?php echo date("d-M",($bodNula + ($tyzden-1)*(7*24*60*60) + (3*24*60*60) )) ?></th>
        <th style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (4*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="2"><?php echo date("d-M",($bodNula + ($tyzden-1)*(7*24*60*60) + (4*24*60*60) )) ?></th>
        <th style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (5*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="2"><?php echo date("d-M",($bodNula + ($tyzden-1)*(7*24*60*60) + (5*24*60*60) )) ?></th>
        <th style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (6*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="2"><?php echo date("d-M",($bodNula + ($tyzden-1)*(7*24*60*60) + (6*24*60*60) )) ?></th>
    </tr>
    <tr style="background: #e4c9ff">
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (0*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">príchod</td>
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (0*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">odchod</td>
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (1*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">príchod</td>
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (1*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">odchod</td>
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (2*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">príchod</td>
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (2*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">odchod</td>
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (3*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">príchod</td>
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (3*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">odchod</td>
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (4*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">príchod</td>
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (4*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">odchod</td>
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (5*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">príchod</td>
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (5*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">odchod</td>
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (6*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">príchod</td>
        <td style="border: 1px solid black<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + (6*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="1">odchod</td>
    </tr>
    <tr>
        <?php
        for ($i=0;$i<23;$i++) {
            echo '<td style="width:70px; height: 5px;"></td>';
        }
        ?>
    </tr>
    <?php
    $zam_s = "SELECT * FROM z WHERE patri_k='".$veduci_oddelenia."' ORDER BY poradie ASC, FIELD(manager, '1', '0', '2') ASC, priezvisko ASC";
    $zam_q = MySQL_Query ($zam_s);
    $bodNula + ($tyzden-1)*(7*24*60*60);
    $iii = 0;
    while ($zam = MySQL_Fetch_Array($zam_q)) {
        $odchod = explode('-', $zam['datum_odchodu']);
        $prichod = explode('-', $zam['datum_prichodu']);
        if ( (((date("U",mktime(0,0,0,$odchod[1],$odchod[2],$odchod[0])))>=($bodNula + ($tyzden-1)*(7*24*60*60)))||($zam['datum_odchodu']=='0000-00-00')) && ((date("U",mktime(0,0,0,$prichod[1],$prichod[2],$prichod[0])))<=($bodNula + ($tyzden-1)*(7*24*60*60) + (6*24*60*60))) ) {
            $iii++;
            if ($zam['poradie']==0) {
                $uloz_i = "UPDATE z SET poradie=".$iii." WHERE id=".$zam['id'];
                $uloz_q = MySQL_Query ($uloz_i);
            }
            ?>
    <tr style="background:<?php if ($iii%2 == 0) {
                echo '#ffffff';
            } else {
                echo '#eaeaea';
                } ?>">
                    <?php
                    if ($upravaPoradia) {
                        ?>  
        <td style="border: 1px solid black" rowspan="3" colspan="1">
            <form action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post">
                <input onchange="upravPoradie(this.value,<?php echo $zam['id'] ?>)" name="zamPoradie" value="<?php echo $zam['poradie'] ?>" type="text" size="3" />
            </form>
        </td>
                    <?php
                } else {
                    ?>
        <td style="border: 1px solid black" rowspan="3" colspan="1">
                        <?php
                        if ($zam['poradie']==0) {
                            echo $iii;
                        } else {
                            echo $zam['poradie'];
                        }
                        ?>
        </td>       
                    <?php
                }
                ?>
        <td style="border: 1px solid black; background: <?php if ($zam['manager']==1) echo '#9beffe'; elseif($zam['manager']==0) echo '#e1f6fa'; else echo '#c9e1e5' ?>" rowspan="3" colspan="2"><?php echo $zam['meno'] .' '. $zam['priezvisko'] ?></td>
        <td style="border: 2px solid black;" rowspan="3" colspan="1" id="nocna<?php echo $zam['id'] ?>">
                    <?php
                    if ($zam['manager']!=1) {
                        $vypis = 0;
                        $sum = vypocitajFinalnyNocnyKtyzdnu($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) - (1*24*60*60) ));
                        $vypis += $sum;
                        echo $vypis;
                    } else {
                        echo '-';
                    }
                    ?>
        </td>
        <td style="border: 2px solid black;" rowspan="3" colspan="1" id="sviatok<?php echo $zam['id'] ?>">
                    <?php
                    if ($zam['manager']!=1) {
                        $vypis = 0;
                        $sum = vypocitajFinalnySviatokKtyzdnu($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) - (1*24*60*60) ));
                        $vypis += $sum;
                        echo $vypis;
                    } else {
                        echo '-';
                    }
                    ?>
        </td>
        <td style="border: 2px solid black;" rowspan="3" colspan="1" id="strava<?php echo $zam['id'] ?>">
                    <?php
                    $vypis = 0;
                    $vypis += vypocitajFinalnuStravuKtyzdnu($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) - (1*24*60*60) ));
                    echo $vypis;
                    ?>
        </td>
        <td style="border: 2px solid black;" rowspan="3" colspan="1" id="nadcas<?php echo $zam['id'] ?>">
                    <?php
                    if ($zam['manager']!=2) {
                        $vypis = 0;
                        $sum = vypocitajFinalnyNadcasKtyzdnu($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) - (1*24*60*60) ));
                        $vypis += $sum;
                        echo $vypis;
                    } else {
                        $vypis = 0;
                        $sum = pocetOdpracovanychHodinKtyzdnu($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) - (1*24*60*60) ));
                        $vypis += $sum;
                        echo $vypis;
                    }
                    ?>
        </td>
        <td style="border: 2px solid black;" rowspan="3" colspan="1" id="mod<?php echo $zam['id'] ?>">
                    <?php
                    if ($zam['manager']==1) {
                        $vypis = 0;
                        $sum = vypocitajFinalnyModKtyzdnu($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) - (1*24*60*60) ));
                        $vypis += $sum;
                        echo $vypis;
                    } else {
                        echo '-';
                    }
                    //echo vypocitatMOD($zam['id'], $bodNula + ($tyzden-1)*(7*24*60*60));
                    ?>
        </td>
        <td style="border: 1px solid black;height: 20px" rowspan="1" colspan="1"><?php echo ($zam['fond']/5) ?> h./deň </td>
                <?php
                for ($k=0;$k<7;$k++) {
                    if ($zam['manager']==1) {
                        $dateAkt = $bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60);
                        if ((date("w",$dateAkt)==0)||(date("w",$dateAkt)==6)||(jeSviatok(date("U",$dateAkt)))) {
                            vlozPlan($zam['id'],$bodNula,$tyzden,$k,'DO');
                        } else {
                            vlozPlan($zam['id'],$bodNula,$tyzden,$k);
                        }
                    } else {
                        vlozPlan($zam['id'],$bodNula,$tyzden,$k);
                    }
                    ?>
        <td style="border: 1px solid black;<?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60) ))) echo '; background: yellow' ?>" rowspan="1" colspan="2">
                        <?php
                        //echo ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60));
                        //echo "<br/>";
                        //echo date("U", mktime(0, 0, 0, $prichod[1], $prichod[2], $prichod[0]));
                        //echo "<br/>";
                        //echo date("U", mktime(0, 0, 0, $odchod[1], $odchod[2], $odchod[0]));
                        ?>
            <select <?php if ($block) echo "disabled "; elseif (zablokovanyDen($dochMesiac2, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))) echo "disabled "; else zablokovany($odchod, $prichod, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60))); ?> size="1" name="type" style="width: 120px;height: 18px;font-size: 13px;" onchange="pridajDochadzku('<?php echo $zam['id'] ?>','<?php echo ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)) ?>',this.value)">
                <?php
                /*
                 * <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='P') echo 'selected="selected"' ?> value="P" style="background: <?php echo $farby[0] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[0] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='D') echo 'selected="selected"' ?> value="D" style="background: <?php echo $farby[1] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[1] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='DP') echo 'selected="selected"' ?> value="DP" style="background: <?php echo $farby[2] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[2] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='LV') echo 'selected="selected"' ?> value="LV" style="background: <?php echo $farby[3] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[3] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='LVP') echo 'selected="selected"' ?> value="LVP" style="background: <?php echo $farby[4] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[4] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='PN') echo 'selected="selected"' ?> value="PN" style="background: <?php echo $farby[5] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[5] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='DO') echo 'selected="selected"' ?> value="DO" style="background: <?php echo $farby[6] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[6] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='OT') echo 'selected="selected"' ?> value="OT" style="background: <?php echo $farby[7] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[7] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='OTP') echo 'selected="selected"' ?> value="OTP" style="background: <?php echo $farby[8] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[8] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='MD') echo 'selected="selected"' ?> value="MD" style="background: <?php echo $farby[9] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[9] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='SPL') echo 'selected="selected"' ?> value="SPL" style="background: white;height: 15px;font-size: 12px;">SPLIT</option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='A') echo 'selected="selected"' ?> value="A" style="background: <?php echo $farby[11] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[11] ?></option>
                            <?php
                            if ($zam['manager']==1) {
                                ?>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='MOD') echo 'selected="selected"' ?> value="MOD" style="background: <?php echo $farby[10] ?>;height: 15px;font-size: 12px;"><?php echo $hodnoty[10] ?></option>
                                <?php
                            }
                            ?>
                 */
                ?>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='P') echo 'selected="selected"' ?> value="P" style="background: <?php echo $farby[0] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[0] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='D') echo 'selected="selected"' ?> value="D" style="background: <?php echo $farby[1] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[1] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='LV') echo 'selected="selected"' ?> value="LV" style="background: <?php echo $farby[2] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[2] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='LD') echo 'selected="selected"' ?> value="LD" style="background: <?php echo $farby[9] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[9] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='PN') echo 'selected="selected"' ?> value="PN" style="background: <?php echo $farby[3] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[3] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='DO') echo 'selected="selected"' ?> value="DO" style="background: <?php echo $farby[4] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[4] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='OT') echo 'selected="selected"' ?> value="OT" style="background: <?php echo $farby[5] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[5] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='MD') echo 'selected="selected"' ?> value="MD" style="background: <?php echo $farby[6] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[6] ?></option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='SPL') echo 'selected="selected"' ?> value="SPL" style="background: white;height: 15px;font-size: 12px;">SPLIT</option>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='A') echo 'selected="selected"' ?> value="A" style="background: <?php echo $farby[8] ?>;height: 15px;font-size: 12px;"><?php echo $hodnotyy[8] ?></option>
                            <?php
                            if ($zam['manager']==1) {
                                ?>
                <option <?php if (typDochadzky($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($k*24*60*60)))=='MOD') echo 'selected="selected"' ?> value="MOD" style="background: <?php echo $farby[7] ?>;height: 15px;font-size: 12px;"><?php echo $hodnoty[7] ?></option>
                                <?php
                            }
                            ?>
            </select>
        </td>
                    <?php
                }
                ?>
        
    </tr>
    <tr style="background:<?php if ($iii%2 == 0) {
                echo '#ffffff';
            } else {
                echo '#eaeaea';
                } ?>">
        <td style="border: 1px solid black; height: 20px" rowspan="1" colspan="1">plánované</td>
                <?php
                for ($l=0;$l<7;$l++) {
                    $in = typDochadzky($zam['id'],($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)));
                    ?>
        <td style="border: 1px solid black; background: url('images/<?php echo $in ?>.png') <?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60) ))) echo 'yellow'; else echo 'transparent'; ?>" rowspan="1" colspan="1" class="day<?php echo $zam['id'] ?><?php echo ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)) ?>">
            <input <?php if ($block) echo "disabled "; elseif (zablokovanyDen($dochMesiac2, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)))) echo "disabled "; else zablokovany($odchod, $prichod, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60))); ?> <?php if(($in=='P')||($in=='SPL')) echo 'style="display: inline"'; ?> id="<?php echo $zam['id'].($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)).'1' ?>" class="zadajPlan" name="" type="text" size="5"  maxlength="5" onchange="nastavTerminy(<?php echo $zam['id'] ?>,<?php echo ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)) ?>,1,this.value)" value="<?php echo vyplnenyCas($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)), 1) ?>" />
            <br/>
            <input <?php if ($block) echo "disabled "; elseif (zablokovanyDen($dochMesiac2, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)))) echo "disabled "; else zablokovany($odchod, $prichod, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60))); ?> <?php if($in=='SPL') echo 'style="display: inline"'; ?> id="<?php echo $zam['id'].($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)).'5' ?>" class="zadajPlan" name="" type="text" size="5"  maxlength="5" onchange="nastavTerminy(<?php echo $zam['id'] ?>,<?php echo ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)) ?>,5,this.value)" value="<?php echo vyplnenyCas($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)), 5) ?>" />
        </td>
        <td style="border: 1px solid black; background: url('images/<?php echo $in ?>.png') <?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60) ))) echo 'yellow'; else echo 'transparent'; ?>" rowspan="1" colspan="1" class="day<?php echo $zam['id'] ?><?php echo ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)) ?>">
            <input <?php if ($block) echo "disabled "; elseif (zablokovanyDen($dochMesiac2, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)))) echo "disabled "; else zablokovany($odchod, $prichod, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60))); ?> <?php if(($in=='P')||($in=='SPL')) echo 'style="display: inline"'; ?> id="<?php echo $zam['id'].($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)).'2' ?>" class="zadajPlan" name="" type="text" size="5"  maxlength="5" onchange="nastavTerminy(<?php echo $zam['id'] ?>,<?php echo ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)) ?>,2,this.value)" value="<?php echo vyplnenyCas($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)), 2) ?>" />
            <br/>
            <input <?php if ($block) echo "disabled "; elseif (zablokovanyDen($dochMesiac2, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)))) echo "disabled "; else zablokovany($odchod, $prichod, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60))); ?> <?php if($in=='SPL') echo 'style="display: inline"'; ?> id="<?php echo $zam['id'].($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)).'6' ?>" class="zadajPlan" name="" type="text" size="5"  maxlength="5" onchange="nastavTerminy(<?php echo $zam['id'] ?>,<?php echo ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)) ?>,6,this.value)" value="<?php echo vyplnenyCas($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)), 6) ?>" />
        </td>
                    <?php
                }
                ?>
    </tr>
    <tr style="background:<?php if ($iii%2 == 0) {
                echo '#ffffff';
            } else {
                echo '#eaeaea';
                } ?>">
        <td style="border: 1px solid black; height: 20px" rowspan="1" colspan="1"><b>reálne</b></td>
                <?php
                for ($l=0;$l<7;$l++) {
                    $in = typDochadzky($zam['id'],($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)));
                    ?>
        <td style="border: 1px solid black; background: url('images/<?php echo $in ?>.png') <?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60) ))) echo 'yellow'; else echo 'transparent'; ?>" rowspan="1" colspan="1" class="day<?php echo $zam['id'] ?><?php echo ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)) ?>"><input <?php if ($block) echo "disabled "; elseif (zablokovanyDen($dochMesiac2, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)))) echo "disabled "; else zablokovany($odchod, $prichod, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60))); ?> <?php if(($in=='P')||($in=='SPL')) echo 'style="display: inline"'; ?> id="<?php echo $zam['id'].($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)).'3' ?>" class="zadajPlan" name="" type="text" size="5"  maxlength="5" onchange="nastavTerminy(<?php echo $zam['id'] ?>,<?php echo ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)) ?>,3,this.value)" value="<?php echo vyplnenyCas($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)), 3) ?>" /></td>
        <td style="border: 1px solid black; background: url('images/<?php echo $in ?>.png') <?php if (jeSviatok(($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60) ))) echo 'yellow'; else echo 'transparent'; ?>" rowspan="1" colspan="1" class="day<?php echo $zam['id'] ?><?php echo ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)) ?>"><input <?php if ($block) echo "disabled "; elseif (zablokovanyDen($dochMesiac2, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)))) echo "disabled "; else zablokovany($odchod, $prichod, ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60))); ?> <?php if(($in=='P')||($in=='SPL')) echo 'style="display: inline"'; ?> id="<?php echo $zam['id'].($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)).'4' ?>" class="zadajPlan" name="" type="text" size="5"  maxlength="5" onchange="nastavTerminy(<?php echo $zam['id'] ?>,<?php echo ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)) ?>,4,this.value)" value="<?php echo vyplnenyCas($zam['id'], ($bodNula + ($tyzden-1)*(7*24*60*60) + ($l*24*60*60)), 4) ?>" /></td>
                        <?php
                    }
                    ?>
    </tr>
    <tr>
                <?php
                for ($i=0;$i<23;$i++) {
                    echo '<td style="width:50px; height: 5px;"></td>';
                }
                ?>
    </tr>
            <?php
        }
    }
    ?>
</table>
<!-- legenda -->
<table>
    <?php
    for ($l=1;$l<count($hodnoty3);$l++) {
        echo '<tr style="background: '.$farby[$l].'"><td>'.$hodnotyy[$l].'</td><td>'.$hodnoty3[$l].'</td></tr>';
    }
    ?>
</table>
<!-- koniec legendy -->
<script type="text/javascript">
$(document).ready(function(){
    
    $('#overlay').css("opacity", '0.90');
    $('#overlay').css('filter', 'alpha(opacity=90)');
    $('#overlay').css('position', 'absolute');
    $('#overlay').css('left', '0');
    $('#overlay').css('top', '0');
    $('#overlay').css('background', '#000000');
    $('#overlay').css('width', $("html").width());
    $('#overlay').css('height', $("html").height());
    $('#overlay').css('z-index', '1000');
    $('#overlay').css('display', 'none');
    
});
</script>

<div id="overlay">
    <div style="background: white; width: 500px; text-align: center; padding: 20px; margin: 200px auto; color: black">Prepočítavajú sa nadčasy, prosím počkajte, kým tento oznam zmizne.</div>
</div>